﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/25/2009
 * Time: 11:26 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NHibernate;
using System.Collections.Generic;
using System.Data;
using Miming.Model.Dao.Interface;

namespace Miming.Model.Dao.NHibernate
{
	/// <summary>
	/// Description of NHibernateSalesTaxCodeDao.
	/// </summary>
	public class NHibernateSalesTaxCodeDao : ISalesTaxCodeDao
	{
		public NHibernateSalesTaxCodeDao()
		{
		}
		
		public void SaveOrUpdate(SalesTaxCode code)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.SaveOrUpdate(code);
			session.Flush();
		}
		
		public void Delete(SalesTaxCode code)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.Delete(code);
			session.Flush();
		}
		
		public SalesTaxCode ReadByPk(int id)
		{
			return NHibernateHelper.OpenSession().Load<SalesTaxCode>(id);
		}
		
		public IList<SalesTaxCode> FindAll()
		{
			return NHibernateHelper.OpenSession().CreateCriteria(typeof(SalesTaxCode)).List<SalesTaxCode>();
		}
	}
}
